//
//  LZTitleButton.swift
//  Weibo
//
//  Created by lzing on 16/3/24.
//  Copyright © 2016年 lzing. All rights reserved.
//

import UIKit

class LZTitleButton: UIButton {
    /// convenience To make button
    convenience init(title: String, imageName: String, target: AnyObject?, action: Selector) {
        self.init()
        setTitle(title, forState: UIControlState.Normal)
        setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        addTarget(target, action: action, forControlEvents: UIControlEvents.TouchUpInside)
        sizeToFit()
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        titleLabel!.frame.origin.x = 0
        imageView!.frame.origin.x = titleLabel!.frame.size.width + 5
    }
}
